// Package main provides ...
package main

import (
	"fmt"
	"time"
)

func main() {
	ticker := time.NewTicker(time.Microsecond * 500)
	stopper := time.NewTimer(time.Microsecond * 3000)

	var i int

	for {
		//多路复用
		select {
		case <-stopper.C: //计时器到时了
			fmt.Println("stop")
			//跳出循环
			goto StopHere
		case <-ticker.C: //打点器触发
			i++ // 打点计数
			fmt.Println("tick :", i)
		}
	}

StopHere:
	fmt.Println("done")
}
